package com.zhengze;

import java.util.regex.Pattern;

public class Demo6 {
    public static void main(String[] args) {
        String re = "(\\d{3,4}\\-(\\d{8,9}))";
        // 1、获取一个Pattern对象
        Pattern pattern = Pattern.compile(re);

        // 2、用这个Pattern对象进行多次匹配（一次编译），效率高
        boolean m1 = pattern.matcher("123-12345678").matches();
        boolean m2 = pattern.matcher("1234-123456789").matches();
        boolean m3 = pattern.matcher("111-12345678").matches();
        System.out.println(m1);
        System.out.println(m2);
        System.out.println(m3);
    }
}
